﻿@using QuocHoi_TV_Frontend.Models
@{
    ViewBag.Title = "ScheduleHome";
    Layout = "~/Views/Shared/_Broadcast.cshtml";     
}

<section id="content">
    <div class="box_tv_live">
        <div class="tile_box_tv_live">
            <div class="link_cata">
                Lịch phát sóng
           
            </div>
        </div>
        <div class="day_lps">
            <ul id="schedule">
                @try
                {
                    int i = 0;
                    foreach (var itemDate in ViewBag.lstdateofweek)
                    {
                        string name = itemDate.NameDay.ToString() + " (" + UtilDate.FormatDateMacth(DateTime.Parse(itemDate.date.ToString())) + ")";
                        string act = "";
                        if ((bool)itemDate.Active == true)
                        {
                            act = "class=\"active\"";
                        }
                        <li @Html.Raw(act) id="sche_@i" onclick="changeStyle(@i)">
                            @Ajax.ActionLink(name, "ScheduleHome",
                                            new { date = itemDate.date, ib = 2 },
                                            new AjaxOptions
                                            {
                                                UpdateTargetId = "lstschedulebydate",
                                                InsertionMode = InsertionMode.Replace,
                                                HttpMethod = "GET"
                                            })
                        </li>
                        i++;
                    }
                    
                }
                catch (Exception)
                {

                }

            </ul>
        </div>
    </div>
    <div class="details_lps">
							
		<ul class="right_details_lps" id="sub">
			<li class="active" id="sub_1">				
                <a><span onclick="loaddata(1)" style="cursor:pointer">Sáng</span></a>
			</li>
			<li class="" id="sub_2">
				<a><span onclick="loaddata(2)" style="cursor:pointer">Chiều</span></a>
			</li>
			<li class="" id="sub_3">
				<a><span onclick="loaddata(3)" style="cursor:pointer">Cả ngày</span></a>
			</li>
		</ul>
	</div>
        <div id="lstschedulebydate">@Html.Partial("_ScheduleDate")</div>

   
</section>
<script type="text/javascript">
    function changeStyle(id) {
        if ($("#schedule li").hasClass("active")) {
            $("#schedule li").removeClass("active");
            $("#sche_" + id).addClass("active");
        }
    }
    function loaddata(id) {
        var APIURL = "/ScheduleTV/SessionOfDay";
        var date = $('#dateSchedule').val();
        
        $.ajax({
            type: "POST",
            url: APIURL,
            data: { 'ib': id, 'date': date },
            success: function (data) {
                $('#lstschedulebydate').html(data);
                if ($("#sub li").hasClass("active")) {
                    $("#sub li").removeClass("active");
                    $("#sub_"+id).addClass("active");
                }
            }
        });
    }
   
</script>